extends Node

var score1 = 0
var score2 = 0
var ball: RigidBody2D
var player1: CharacterBody2D
var player2: CharacterBody2D

func _ready():
	ball = $Ball
	player1 = $Player1
	player2 = $Player2
	
	# 设置球的初始物理属性
	ball.gravity_scale = 0.5
	ball.linear_damp = 0.1
	
	# 连接信号
	ball.body_entered.connect(_on_ball_body_entered)

func _on_ball_body_entered(body):
	if body.has_method("hit_ball"):
		body.hit_ball(ball)

func update_score():
	$UI/Score1.text = "玩家1: " + str(score1)
	$UI/Score2.text = "玩家2: " + str(score2)

# 移除reset_ball和_out_of_bounds相关逻辑

func _process(delta):
	pass # 不再检测球是否出界
